package com.yan.edu.controller;


import com.yan.commonutils.R;
import com.yan.edu.entity.subject.OneSubject;
import com.yan.edu.service.SubjectService;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * <p>
 * 课程科目 前端控制器
 * </p>
 *
 * @author testjava
 * @since 2020-09-17
 */

@RestController
@RequestMapping("/edu/subject")
@CrossOrigin
public class SubjectController {
    @Autowired
    private SubjectService subjectService;
    @ApiOperation(value = "上传Excel表格到数据库")
    @PostMapping("addSubject")
    public R addSubject(MultipartFile file) {
        //上传过来excel文件
        subjectService.saveSubject(file,subjectService);
        return R.ok();
    }
    @ApiOperation(value = "课程分类列表（树型）")
    @GetMapping("getAllSubject")
    public R getAllSubject(){
       List<OneSubject> list= subjectService.getOneTwoSubject();

        return R.ok().data("list",list);

    }

}

